﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CONFIG - SMALL SITE, BIG-NEWs</title>
<link rel="icon" href="../favicon.ico" type="image/x-icon"/>

<link href="../res/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
<!-- <link href="../res/common.css" rel="stylesheet" type="text/css" /> -->

<script type="text/javascript" src="../res/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../res/jquery-ui-1.7.2.min.js"></script>

<script type='text/javascript' src='../dwr/interface/configDwr.js'></script>
<script type='text/javascript' src='../dwr/engine.js'></script>


<style type="text/css">
<!--
body {
	margin: 0;
	padding: 0;
	font: 0.75em Tahoma, Geneva, sans-serif;
}
#main {
	margin:0 auto;
	//position:relative;
	width:81em;
}
.config-edit {
}
.config-edit-list {
	list-style: none;
}
.config-edit-list li {
	margin: 0.25em 0;
}
.config-edit-list label {
	display: block;
	float: left;
	width: 20em;
}
.config-edit-list input {
	width: 20em;
}
-->
</style>
<script type="text/javascript">

$(document).ready(function(){
	$('#main').tabs();
	configDwr.readConfig(function(sresult){
		var html = [];
		for(var prop in sresult.result) {
			html = html.concat('<li><label>', prop, '</label><input type="text" value="', sresult.result[prop], '"/></li>');
		}
		$('#config .config-edit-list').html(html.join(''));
	});
	configDwr.readClientConfig(function(sresult){
		var html = [];
		for(var prop in sresult.result) {
			html = html.concat('<li><label>', prop, '</label><input type="text" value="', sresult.result[prop], '"/></li>');
		}
		$('#clientConfig .config-edit-list').html(html.join(''));
	});
});

function updateConfig() {
	var config = {};
	$('#config .config-edit-list li').each(function(){
		var prop = $(this).children('label').text();
		config[prop] = $(this).children('input').val();
	});
	configDwr.updateConfig(config, function(sresult){
		//if(sresult.msg != "OK")
			alert(sresult.msg);
	});
}
function updateClientConfig() {
	var config = {};
	$('#clientConfig .config-edit-list li').each(function(){
		var prop = $(this).children('label').text();
		config[prop] = $(this).children('input').val();
	});
	configDwr.updateClientConfig(config, function(sresult){
		//if(sresult.msg != "OK")
			alert(sresult.msg);
	});
}
</script>
</head>

<body>
<div id="main">

	<ul>
		<li><a href="#config">Config</a></li>
		<li><a href="#clientConfig">ClientConfig</a></li>
	</ul>
	
	<div id="config" class="">
		<ul class="config-edit-list">
			<li><label>config</label><input type="text" value=""/></li>
		</ul>
		<input type="button" value="更新" onclick="updateConfig()" />
	</div>
	<div id="clientConfig" class="">
		<ul class="config-edit-list">
			<li><label>config</label><input type="text" value=""/></li>
		</ul>
		<input type="button" value="更新" onclick="updateClientConfig()" />
	</div>
	
</div>
</body>
</html>
